package com.aero.cojbackendmodel.model.vo;

import com.aero.cojbackendmodel.model.entity.Reply;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * 用户视图（脱敏）
 *
 * @author Aero

 */
@Data
public class ReplyVO implements Serializable {

    /**
     * 评论回复表主键id
     */
    @TableId(type = IdType.ASSIGN_ID)
    private Long id;

    /**
     * 评论id
     */
    private Long commentId;

    /**
     * 回复的作者的id
     */
    private Long userId;

    /**
     * 该回复属于哪个题目
     */
    private Long questionId;

    /**
     * 回复父Id
     */
    private Long parentReplyId;

    /**
     * 父评论用户名
     */
    @TableField(exist = false)
    private String replyUserName;

    /**
     * 回复内容
     */
    private String content;

    /**
     * 用户脱敏信息
     */
    private UserVO userVO;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTIme;


    /**
     * 包装类转对象
     *
     * @param replyVO
     * @return
     */
    public static Reply voToObj(ReplyVO replyVO) {
        if (replyVO == null) {
            return null;
        }
        Reply reply = new Reply();
        BeanUtils.copyProperties(replyVO, reply);
        return reply;
    }

    /**
     * 对象转包装类
     *
     * @param reply
     * @return
     */
    public static ReplyVO objToVo(Reply reply) {
        if (reply == null) {
            return null;
        }
        ReplyVO replyVO = new ReplyVO();
        BeanUtils.copyProperties(reply, replyVO);
        return replyVO;
    }

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;
}